package cn.com.system.controller;


import cn.com.system.pojo.Role;
import cn.com.system.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/role")
public class loginController {
    @Resource
    private RoleService roleService;

    @RequestMapping("login.do")
    public String loginDo(){
        return "login";
    }

    @RequestMapping("index.do")
    public String index(){
        return "index";
    }

    @RequestMapping("/login")
    public String login( String Name, String Password, HttpSession session) {
        Role role=roleService.selectAll(Name,Password);
        if (role!=null){
            session.setAttribute("Name",Name);
            return "index";
        }else {
            return "redirect:/role/login.do";
        }

    }

}
